<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:replace="nav :: navHeaderIFrameItem(~{::title})">
    <title>雪花编辑功能</title>
</head>
<body>
    <div id="form_win">
        <form class="layui-form" lay-filter="formData">
            <div class="layui-form-item">
                <label class="layui-form-label">业务类型</label>
                <div class="layui-input-block">
                    <input type="text" name="bizType" required  lay-verify="required" placeholder="业务类型" autocomplete="off" class="layui-input" disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">起始值</label>
                <div class="layui-input-block">
                    <input type="text" name="beginId" required  lay-verify="required" placeholder="起始值" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">步长</label>
                <div class="layui-input-block">
                    <input type="text" name="step" required  lay-verify="required" placeholder="步长" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否初始化</label>
                <div class="layui-input-block">
                    <input type="radio" name="isNeedInit" value="是" title="是">
                    <input type="radio" name="isNeedInit" value="否" title="否" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                </div>
            </div>
        </form>
    </div>
    <div th:include="nav::navFooterIFrameItem" ></div>
    <script>
        layui.use('form', function(){
            let form = layui.form,
                $ = layui.$;

            // $.ajax({
            //     type: "post",
            //     url: "/layui/formSubmit",
            //     data:{},
            //     dataType:"json",
            //     success:function(result){
            let data= {
                "bizType": "1",
                "beginId": "123456",
                "step": "1",
                "isNeedInit": "否"
            }
            // if(result.code===200){

            form.val('formData',data);
            // }else{
            //     layer.msg("错误码为200");
            // }
            //     },
            //     error : function(e){
            //         layer.msg('服务异常');
            //     }
            // });

            //监听提交
            form.on('submit(formDemo)', function(data){
                const index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
                top.layer.close(index);
                close_layer();

                //ajax请求的参数直接用data.field获取表单里含有name属性的元素的值
                // $.ajax({
                //     type: "post",
                //     url: "/layui/formSubmit",
                //     data:data.field,
                //     dataType:"json",
                //     success:function(){
                //          top.layer.close(index);
                //         if(d.code===200){
                //             layer.msg("请求成功");
                //
                //         }else{
                //             layer.msg("错误码为200");
                //
                //         }
                //     },
                //     error : function(e){
                //         layer.msg('服务异常');
                //           top.layer.close(index);
                //     }
                // });
                return false;
            });
        });

        //关闭弹窗
        function close_layer() {
            let index = parent.layer.getFrameIndex(window.name);
            parent.window.frames["winCon"].layui.table.reload('tableData');
            parent.layer.close(index);
        }
    </script>
</body>
</html>